#ifndef __BASE_LOGGER_H__
#define __BASE_LOGGER_H__

#include <sstream>
#include <string>

#define LOG(Level, logger, logEvent)					\
	{													\
		std::ostringstream oss;							\
		oss << logEvent;								\
		logger.##Level(oss.str(), __FILE__, __LINE__);	\
	}

class LoggerImpl;
class Logger
{
public:
	Logger(LoggerImpl * pLoggerImpl);
	~Logger();
	static Logger& GetInstance();
	static Logger& GetInstance(const std::string& strName);
	void Trace(const std::string& rMessage, const char* szFileName = 0, int nLine = -1);
	void Debug(const std::string& rMessage, const char* szFileName = 0, int nLine = -1);
	void Info(const std::string& rMessage, const char* szFileName = 0, int nLine = -1);
	void Warn(const std::string& rMessage, const char* szFileName = 0, int nLine = -1);
	void Error(const std::string& rMessage, const char* szFileName = 0, int nLine = -1);
private:
	LoggerImpl * m_pLoggerImpl;
};

#define LOG_TRACE(logger, logEvent) LOG(Trace, logger, logEvent)
#define LOG_DEBUG(logger, logEvent) LOG(Debug, logger, logEvent)
#define LOG_INFO(logger, logEvent) LOG(Info, logger, logEvent)
#define LOG_WARN(logger, logEvent) LOG(Warn, logger, logEvent)
#define LOG_ERROR(logger, logEvent) LOG(Error, logger, logEvent)

#define DEFAULT_LOG_TRACE(logEvent) LOG_TRACE(Logger::GetInstance(), logEvent)
#define DEFAULT_LOG_DEBUG(logEvent) LOG_DEBUG(Logger::GetInstance(), logEvent)
#define DEFAULT_LOG_INFO(logEvent)  LOG_INFO(Logger::GetInstance(), logEvent)
#define DEFAULT_LOG_WARN(logEvent)  LOG_WARN(Logger::GetInstance(), logEvent)
#define DEFAULT_LOG_ERROR(logEvent) LOG_ERROR(Logger::GetInstance(), logEvent)

#endif //__BASE_LOGGER_H__